﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace Data
{
    class connection
    {        

        public static SqlConnection Connect(string ip, string database)
        {
            SqlConnection cn = new SqlConnection();
            try
            {
                if (cn.State == ConnectionState.Broken || cn.State == ConnectionState.Closed)
                {
                    string sketnoi = @"Data Source=" + ip + ";Initial Catalog=" + database + ";Integrated Security=True";
                    cn.ConnectionString = sketnoi;
                    cn.Open();
                }
                return cn;
            }
            catch
            {
                return null;
            }
        }

    }
}
